package com.culturalCenter.dataCenter.mapper.user;

import com.culturalCenter.dataCenter.entity.user.UserDayNumber;
import com.culturalCenter.dataCenter.mapper.base.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserDayNumberMapper extends BaseMapper<UserDayNumber> {

    /**
     * 通过用户id查询
     *
     * @param userId 用户id
     *
     * @return
     */
    List<UserDayNumber> queryByUserId(@Param("userId") String userId);

    /**
     * 根据日期查询
     *
     * @param date
     *
     * @return
     */
    @Select("SELECT * FROM cdc_user_day_number WHERE currentTime =#{date}")
    UserDayNumber selectByDate(@Param("date") String date);

    /**
     * 根据月份查询
     *
     * @param date
     *
     * @return
     */
    List<UserDayNumber> selectByMonth(@Param("date") String date);

    /**
     * 批量插入数据
     *
     * @param userDayNumberList
     */
    void insertBatch(@Param("list") List<UserDayNumber> userDayNumberList);

    /**
     * 删除所有数据
     */
    @Delete("TRUNCATE cdc_user_day_number")
    void deleteAll();

}
